Skip to main content

AAPT error unexpected element queries found in manifest.

自己接入聚合广告SDK后,打包报这个错,折腾了2天,下面介绍方法.

error: unexpected element <queries> found in <manifest>.

* What went wrong:
Execution failed for task ':launcher:processReleaseResources'.
> Android resource linking failed
F:\SVN\AnimalTopia\branch-yyy\client\Temp\gradleOut\launcher\build\intermediates\merged_manifests\release\AndroidManifest.xml:48: AAPT: error: unexpected element <queries> found in `<manifest>`.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

解决方法:

第一种:

打开Unity的安装文件目录: 例如

E:\Program Files\Unity\2019.4.16f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates\baseProjectTemplate.gradle

打开后,把 classpath 'com.android.tools.build:gradle:3.4.0' 改成 classpath 'com.android.tools.build:gradle:3.4.3'

第二种:

https://developer.android.com/studio/releases/gradle-plugin#3-6-0-new

  1. 打开 Build settings -> Player Settings 的这个地方,勾选 打开提示的文件

2.修改内容

classpath 'com.android.tools.build:gradle:3.4.0' 改为 classpath 'com.android.tools.build:gradle:3.4.3'

allprojects {
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
}

dependencies {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
classpath 'com.android.tools.build:gradle:3.4.3'
**BUILD_SCRIPT_DEPS**
}
}

repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}